<script>
import { Button } from "element-ui";
export default {
  name: "ElButton",
  extends: Button,
  props: {
    throttle: {
      type: Boolean,
      default: true,
    },
  },
  mounted() {
    this.$el.addEventListener("click", this.handleThrottle.bind(this));
  },
  beforeDestroy() {
    this.$el.removeEventListener("click", this.handleThrottle.bind(this));
  },
  methods: {
    handleThrottle(e) {
      if (this.$el.disabled || !this.throttle) return;
      this.$el.classList.add("is-disabled");
      this.$el.disabled = true;
      setTimeout(() => {
        this.$el.disabled = false;
        this.$el.classList.remove("is-disabled");
      }, 1500);
    },
  },
};
</script>

<style lang="scss" scoped></style>
